<?php get_header(); ?>
<div class="full-tour">
	<?php 
	if (have_posts()) : the_post(); 
	$date_format=ThemexCore::getOption('date_format','m/d/Y');
	$destinations=themex_category($post->ID, 'destination');
	$url_destinations=themex_category_url($post->ID, 'destination');
	$price=themex_price($post->ID);
	$website=get_post_meta($post->ID,'_tour_website',true);
	$address=get_post_meta($post->ID,'_tour_address',true);
	$phone=get_post_meta($post->ID,'_tour_phone',true);
	$cellulare=get_post_meta($post->ID,'_tour_cellulare',true);
	$fax=get_post_meta($post->ID,'_tour_fax',true);
	$email=get_post_meta($post->ID,'_tour_email',true);
	$booking=get_option('themex_tours_booking');
	$questions=get_option('themex_tours_questions');
	$testimonials=get_option('themex_tours_testimonials');	
	parse_str(get_post_meta($post->ID,'_tour_images',true),$gallery);
	?>
	<div class="sixcol column">
		<div class="fade-slider-container tour-slider-container">
			<div class="fade-slider tour-slider">
				<ul>
					<?php foreach($gallery as $image) { ?>
					<li>
						<img src="<?php echo THEMEX_URI; ?>extensions/timthumb/timthumb.php?src=<?php echo $image; ?>&amp;w=527" alt="" />								
					</li>
					<?php } ?>
				</ul>
				<div class="arrow arrow-left fade-slider-arrow"></div>
				<div class="arrow arrow-right fade-slider-arrow"></div>
				<input type="hidden" class="slider-speed" value="400" />
				<input type="hidden" class="slider-pause" value="0" />
			</div>
			<div class="block-background layer-1"></div>
			<div class="block-background layer-2"></div>
		</div>
	</div>
	<div class="sixcol column last">
		<div class="block-title">
			<h1><?php the_title(); ?></h1>				
		</div>
		<?php if($address!='' || $price!='' || $destinations!='' || $website!='') { ?>
		<ul class="tour-meta">
			<?php if($website!='') { ?><li><div class="colored-icon icon-5"><span></span></div><strong><?php _e('Sito web','midway'); ?>:</strong> <a target="_blank" rel="nofollow" href="<?php echo $website; ?>"><?php echo $website; ?></a></li><?php } ?>
			<?php if($address!='') { ?><li><div class="colored-icon icon-2"><span></span></div><strong><?php _e('Indirizzo','midway'); ?>:</strong> <?php echo $address; ?></li><?php } ?>
			<?php if($destinations!='') { ?><li><div class="colored-icon icon-2"></div><strong><?php _e('Destination','midway'); ?>:</strong> <a href="<?php echo $url_destinations; ?>"><?php echo $destinations; ?></a></li><?php } ?>
			<?php if($phone!='') { ?><li><div class="colored-icon icon-5"><span></span></div><strong><?php _e('Telefono','midway'); ?>:</strong> <?php echo $phone; ?></li><?php } ?>
			<?php if($cellulare!='') { ?><li><div class="colored-icon icon-5"><span></span></div><strong><?php _e('Cellulare','midway'); ?>:</strong> <?php echo $cellulare; ?></li><?php } ?>
			<?php if($fax!='') { ?><li><div class="colored-icon icon-5"><span></span></div><strong><?php _e('Fax','midway'); ?>:</strong> <?php echo $fax; ?></li><?php } ?>
			<?php if($email!='') { ?><li><div class="colored-icon icon-5"><span></span></div><strong><?php _e('Email','midway'); ?>:</strong> <?php echo $email; ?></li><?php } ?>
			<?php if($price!='') { ?><li><div class="colored-icon icon-3"><span></span></div><strong><?php _e('Price','midway'); ?>:</strong> <?php echo $price; ?></li><?php } ?>
			<?php if(function_exists('the_views')) { ?><li><div class="colored-icon icon-5"><span></span></div><strong><?php _e('Questo Bed and Breakfast &egrave; stato visualizzato','midway'); ?>:</strong> <?php the_views(); ?></li><?php } ?>
		</ul>
		<?php } ?>
		<?php the_excerpt(); ?>
		<?php if($booking!='true') { ?><a href="#booking-form" data-id="<?php echo $post->ID; ?>" data-title="<?php the_title(); ?>" class="button small fancybox tour-button"><span><?php _e('Book Now','midway'); ?></span></a><?php } ?>
		<?php if($questions!='true') { ?><a href="#question-form" data-id="<?php echo $post->ID; ?>" data-title="<?php the_title(); ?>" class="button grey small fancybox tour-button"><span><?php _e('Ask a Question','midway'); ?></span></a><?php } ?>
		<?php if($testimonials!='true') { ?><a href="#testimonial-form" data-id="<?php echo $post->ID; ?>" data-title="<?php the_title(); ?>" class="button grey small fancybox tour-button"><span><?php _e('Scrivi una recensione','midway'); ?></span></a><?php } ?>
		<?php get_template_part('module','forms'); ?>
	</div>		
	<div class="clear"></div>
</div>

<?php the_content(); ?>	

<?php if(false && get_option('themex_tours_related')!='true') { 	?>
<div class="related-tours">
	<div class="block-title"><h1><?php _e('Related Tours','midway'); ?></h1></div>
	<?php
	$order=ThemexCore::getOption('tours_related_order','rand');
	$taxonomies=array($order);
	if($order!='rand') {
		$taxonomies=wp_get_post_terms($post->ID,'tour_'.$order);
		shuffle($taxonomies);
	}

	$used_posts[]=$post->ID;	
	$post_count=0;
	
	foreach ($taxonomies as $taxonomy) {
		if($post_count<4) {
			$args=array(
			  'tour_'.$order => $order=='rand'?null:$taxonomy->slug,
			  'post__not_in' => $used_posts,
			  'post_type' => 'tour',
			  'orderby' => 'rand',
			  'meta_key'    => '_thumbnail_id',
			  'showposts'=>4,
			);
			$query = new WP_Query($args);


			while ($query->have_posts() && $post_count<4) {
				$query->the_post(); 
				$destinations=themex_category($post->ID, 'destination');	
				$types=themex_category($post->ID, 'type');
				$duration=themex_duration($post->ID);
				?>
				<div class="column threecol <?php if($post_count==3) echo 'last'; ?>">
					<div class="tour-thumb-container">
						<div class="tour-thumb">						
							<a href="<?php the_permalink(); ?>"><img src="<?php echo themex_thumbnail($post->ID, 460); ?>" class="fullwidth" alt="<?php the_title(); ?>" /></a>
							<div class="tour-caption">
								<h5 class="tour-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
								<?php if($destinations!='' || $duration!='') { ?>
								<div class="tour-meta">
									<?php if($destinations!='') { ?>
									<div class="tour-destination"><div class="colored-icon icon-2"></div><?php echo $destinations; ?></div>
									<?php } ?>
									<?php if($duration!='') { ?>
									<div class="tour-duration"><?php echo $duration; ?></div>
									<?php } ?>
								</div>
								<?php } ?>
							</div>								
						</div>		
						<div class="block-background"></div>
					</div>
				</div>
				<?php
				$used_posts[]=$post->ID;
				$post_count++;
			}
			wp_reset_query();
		}
	}
	?>
	<div class="clear"></div>	
</div>
<?php } ?>
<?php endif; //wp_reset_query(); ?>
<?php get_footer(); ?>